package com.ucode.wap.cgms.controller;

import cn.hutool.log.Log;
import cn.hutool.log.LogFactory;
import com.ucode.cgms.service.CgmsCompanionCategoryService;
import com.ucode.cgms.service.CgmsGiftService;
import com.ucode.cgms.service.CgmsSpecialZoneService;
import com.ucode.model.cgms.CgmsCompanionCategory;
import com.ucode.model.cgms.CgmsGift;
import com.ucode.model.cgms.CgmsSpecialZone;
import com.ucode.model.cgms.convert.CgmsSpecialZoneConvert;
import com.ucode.model.cgms.enums.CgmsGiftStateEnum;
import com.ucode.model.cgms.vo.CgmsSpecialZoneVO;
import com.ucode.tool.base.ResponseResult;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.enums.ParameterIn;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Tag(name = "移动端 - 陪玩社区系统 - 公共业务")
@RestController
@RequestMapping("/cgms/common")
@Validated
public class ApiCgmsCommonController {

    private static Log log = LogFactory.get();
    @Resource
    private CgmsCompanionCategoryService cgmsCompanionCategoryService;
    @Resource
    private CgmsSpecialZoneService cgmsSpecialZoneService;
    @Resource
    private CgmsGiftService cgmsGiftService;

    @GetMapping(value = "/special-zone/list")
    @Operation(summary = "专区配置列表")
    public ResponseResult<List<CgmsSpecialZoneVO>> specialZoneList() {
        List<CgmsSpecialZone> list = cgmsSpecialZoneService.queryListByEnable();
        List<CgmsSpecialZoneVO> vos = CgmsSpecialZoneConvert.INSTANCE.convertList(list);
        return ResponseResult.success();
    }

    @GetMapping(value = "/special-zone/{id}")
    @Parameter(description="主键ID",name = "id", required = true,in = ParameterIn.PATH,example = "1024")
    @Operation(summary = "专区配置信息")
    public ResponseResult<CgmsSpecialZoneVO> getSpecialZone(@PathVariable(name="id",required=true) Long id) {
        return ResponseResult.success();
    }

    @GetMapping(value = "/companion-category/list")
    @Operation(summary = "专区分类列表")
    public ResponseResult<List<CgmsCompanionCategory>> companionCategoryList(@Schema(description = "专区ID") @RequestParam(value = "zoneId", required = false) Long zoneId) {
        List<CgmsCompanionCategory> list = cgmsCompanionCategoryService.queryListByEnable(zoneId);
        return ResponseResult.success(list);
    }

    @Operation(summary = "礼物列表")
    @GetMapping(value = "/gift-list")
    public ResponseResult<List<CgmsGift>> giftList() {
        Map<String,Object> condition = new HashMap<>();
        condition.put("status", CgmsGiftStateEnum.ON_SHELF.getState());
        condition.put("deltag",false);
        List<CgmsGift> list = cgmsGiftService.queryObjectForList(condition,0);
        return ResponseResult.success(list);
    }

}
